﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.UI;
using System.IO;
using System.Drawing;
using System.Web.Hosting;
using TheServer.Models;

namespace TheServer.Controllers
{
    //[HttpHeader("Access-Control-Allow-Origin", "*")]
    public class ChatController : ApiController
    {
        

        // GET api/chat/5
        public List<AccountDTO> GetFriends(string acc, string pass, bool openid)
        {
            return FriendDAO.GetFriend(acc, pass, openid);
        }
        public List<AccountDTO> GetStatusFriends(string acc)
        {
            return FriendDAO.GetStatusFriends(acc);
        }

        public List<MessageDTO> GetMessage(string msg)
        {
            return MessageDAO.GetMessage(msg);
        }

        // POST api/chat
        public List<AccountDTO> Post(string addFriend, string taikhoan, string taikhoanban)
        {
            FriendDTO friend = new FriendDTO();
            friend.TaiKhoan = taikhoan;
            friend.TaiKhoanBan = taikhoanban;
            return FriendDAO.AddFriend(friend);
        }
        public int PostAccount(string signup, [FromBody]AccountDTO acc)
        {
            return AccountDAO.SignUp(signup, acc);
        }

        public int PostMessage(string SendMsg, MessageDTO Msg)
        {
            return MessageDAO.PostMessage(Msg);
        }

        public int PostHinhAnh(string hinhanh, [FromBody]Byte[] StreamImg)
        {
            return AccountDAO.PostHinhAnh(hinhanh, StreamImg);
        }

        // PUT api/chat/5
        public string Put(int id, [FromBody]AccountDTO taikhoanThoat)
        {
            return taikhoanThoat.TaiKhoan;
            
        }

        public int PostLogOut(string logout, [FromBody]AccountDTO taikhoanThoat)
        {
            return AccountDAO.LogOut(taikhoanThoat);
        }

        public List<AccountDTO> PostDeleteFriend(string deleteFriend, string taikhoan, string taikhoanban)
        {
            FriendDTO friendXoa = new FriendDTO();
            friendXoa.TaiKhoan = taikhoan;
            friendXoa.TaiKhoanBan = taikhoanban;
            return FriendDAO.DeleteFriend(friendXoa);
        }



        // DELETE api/chat/5
        public void Delete(int id)
        {
        }
    }
}
